home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / STDLIB.PAK / COUNT.CPP < prev    next >
Text File  |  1997-05-06  |  515b  |  28 lines

  1.  #include <vector>
  2.  #include <algorithm>
  3.  
  4.  using namespace std;
  5.  
  6.  int main ()
  7.  {
  8.    int sequence[10] = {1,2,3,4,5,5,7,8,9,10};
  9.    int i=0,j=0,k=0;
  10.    //
  11.    // Set up a vector.
  12.    //
  13.    vector<int> v(sequence+0, sequence+10);
  14.  
  15.    count(v.begin(),v.end(),5,i);    // Count fives
  16.    count(v.begin(),v.end(),6,j);    // Count sixes
  17.    //
  18.    // Count all less than 8.
  19.    //
  20.    count_if(v.begin(), v.end(), bind2nd(less<int>(),8),k);
  21.  
  22.    cout << i << " " << j << " " << k << endl;
  23.  
  24.    return 0;
  25.  }
  26.  
  27.  
  28.